home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_0799 / 462 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  6.6 KB

  1. Subject: Re: Bug report. MiNT 1.07; more init patches...
  2. Date: Thu, 2 Sep 93 16:15:46 CES
  3. From: Juergen Lock <nox@jelal.north.de>
  4. Message-Id: <9309021415.AA00378@jelal.north.de>
  5.  
  6. Juergen Lock writes:
  7.  
  8. > > Machine:- TT030, 8MB RAM (4+4), standard TT Hard drive + ICD adaptor and
  9. > > 85MB seagate drive on ACSI bus.
  10. > > 
  11. > > (1) When opening serial ports modem2, serial1 and serial2, modem1 is opened.
  12. >  hmm haven't seen that one...  actually my uucico (taylor 1.03) just
  13. > received this mail over modem2, without any problems.  this is MiNT 1.09...
  14.  
  15.  i forgot to say this is a megaSTe, maybe the bug is >68000 specific...
  16.  
  17.  anyway, i now have halt working again (searches init now) and made init
  18. sync minixfs and don't wait for TSRs when killed.  and syslogd now forks
  19. itself into background to reduce fragmentation a bit.
  20.  
  21. diff -ru .b/halt/Makefile ./halt/Makefile
  22. --- .b/halt/Makefile    Thu Aug  5 21:53:48 1993
  23. +++ ./halt/Makefile    Wed Sep  1 17:15:00 1993
  24. @@ -2,7 +2,7 @@
  25.  
  26.  SHELL = /bin/sh
  27.  
  28. -CPPFLAGS = -I../include
  29. +CPPFLAGS = -I../include -DMINT
  30.  
  31.  EXTRALIBS = ../lib/libusers.a ../syslog/libsyslog.a
  32.  
  33. diff -ru .b/halt/halt.c ./halt/halt.c
  34. --- .b/halt/halt.c    Wed Sep  1 16:30:04 1993
  35. +++ ./halt/halt.c    Thu Sep  2 14:45:36 1993
  36. @@ -2,10 +2,66 @@
  37.  #include <signal.h>
  38.  #include <sys/syslog.h>
  39.  
  40. +#ifdef MINT
  41. +#include <ioctl.h>
  42. +#include <sys/dir.h>
  43. +
  44. +typedef unsigned long    ulong;
  45. +
  46. +typedef struct _context {
  47. +    long    regs[15];    /* registers d0-d7, a0-a6 */
  48. +    long    usp;        /* user stack pointer (a7) */
  49. +    short    sr;        /* status register */
  50. +    long    pc;        /* program counter */
  51. +    long    ssp;        /* supervisor stack pointer */
  52. +    long    term_vec;    /* GEMDOS terminate vector (0x102) */
  53. +
  54. +/* these fields were added in MiNT 0.9 */
  55. +    char    fstate[216];    /* FPU internal state */
  56. +    char    fregs[12*8];    /* registers fp0-fp7 */
  57. +    long    fctrl[3];        /* FPCR/FPSR/FPIAR */
  58. +    short    sfmt;            /* stack frame format identifier */
  59. +    long    iar;            /* instruction address */
  60. +    short    internal[4];    /* four words of internal info */
  61. +} CONTEXT;
  62. +
  63. +struct pinfo {
  64. +    long    magic;
  65. +    char    *base;
  66. +    short    pid, ppid, pgrp;
  67. +    short    ruid, rgid;
  68. +    short    euid, egid;
  69. +    short    memflags;
  70. +    short    pri;
  71. +    short    wait_q;
  72. +    long    wait_cond;
  73. +    /* (all times are in milliseconds) */
  74. +    ulong    systime;        /* time spent in kernel        */
  75. +    ulong    usrtime;        /* time spent out of kernel    */
  76. +    ulong    chldstime;        /* children's kernel time     */
  77. +    ulong    chldutime;        /* children's user time        */
  78. +
  79. +    ulong    maxmem;            /* max. amount of memory to use */
  80. +    ulong    maxdata;        /* max. data region for process */
  81. +    ulong    maxcore;        /* max. core memory for process */
  82. +    ulong    maxcpu;            /* max. cpu time to use     */
  83. +
  84. +    short    domain;            /* process domain (TOS or MiNT)    */
  85. +    short    curpri;            /* current priority (nice)    */
  86. +};
  87. +#endif
  88. +
  89.  main(argc, argv)
  90.  int argc;
  91.  char *argv[];
  92.  {
  93. +#ifdef MINT
  94. +    int pid, initpid;
  95. +    DIR *procdir;
  96. +    struct direct *entry;
  97. +    char *pointer;
  98. +#endif
  99. +
  100.      if (getuid() != 0)
  101.      {
  102.          printf("You need to be root to run halt.\n");
  103. @@ -19,8 +75,52 @@
  104.      syslog(LOG_NOTICE, "halted by root");
  105.      closelog();
  106.  
  107. +#ifdef MINT
  108. +    if ((procdir = opendir("u:/proc")) == NULL)
  109. +    {
  110. +        perror("opendir: u:/proc");
  111. +    }
  112. +    else
  113. +    {
  114. +        /* look for process called init with ppid 0
  115. +        */
  116. +        while ((entry = readdir(procdir)) != NULL)
  117. +        {
  118. +            char statf[0x80] = "u:/proc/";
  119. +            int fd;
  120. +
  121. +            entry->d_name[entry->d_namlen] = '\0';
  122. +            pointer = strchr(entry->d_name, '.');
  123. +            sscanf(++pointer, "%3d", &pid);
  124. +            strcpy (statf+sizeof "u:/proc", entry->d_name);
  125. +            if (!strncmp
  126. +                (entry->d_name, "init.", pointer-1-entry->d_name) &&
  127. +                (fd = open (statf, 0)) >=0) {
  128. +                long place;
  129. +                long ctxtsize;
  130. +                struct pinfo proc;
  131. +
  132. +                ioctl(fd, PPROCADDR, &place);
  133. +                if (ioctl(fd, PCTXTSIZE, &ctxtsize) < 0) {
  134. +                    lseek(fd, place+4+2*sizeof(CONTEXT), 0);
  135. +                } else
  136. +                    lseek(fd, place, 0);
  137. +                read(fd, &proc, sizeof(proc));
  138. +                if (proc.pid == pid && proc.ppid <= 0) {
  139. +                    initpid = pid;
  140. +                    break;
  141. +                }
  142. +            }
  143. +        }
  144. +        closedir(procdir);
  145. +    }
  146. +
  147. +    if (kill(initpid, SIGTERM) == -1)
  148. +        perror("kill");
  149. +#else
  150.      if (kill(1, SIGTERM) == -1)
  151.          perror("kill");
  152. +#endif
  153.  
  154.      sleep(1);
  155.  }
  156. diff -ru .b/init/init.c ./init/init.c
  157. --- .b/init/init.c    Thu Sep  2 14:52:40 1993
  158. +++ ./init/init.c    Wed Sep  1 14:54:54 1993
  159. @@ -46,6 +46,7 @@
  160.  #ifdef MINT
  161.  #include <ioctl.h>
  162.  #include <sys/dir.h>
  163. +#include <sys/stat.h>
  164.  #include <mintbind.h>
  165.  
  166.  extern char *strchr();
  167. @@ -59,6 +60,7 @@
  168.  static int shutdown = 0;
  169.  static int exit_anyway = 0;
  170.  static int times_up = 0;
  171. +static int updatepid = 0;
  172.  
  173.  int flags;
  174.  
  175. @@ -364,6 +366,14 @@
  176.      printf("Syncing file systems...");
  177.      fflush(stdout);
  178.  
  179. +#ifdef MINT
  180. +    /* sync minixfs... */
  181. +    if (updatepid) {
  182. +        kill (updatepid, SIGALRM);
  183. +        sleep (5);
  184. +    }
  185. +#endif
  186. +
  187.  #ifdef SYNC_FILESYS
  188.      sync();
  189.      sync();
  190. @@ -417,10 +427,21 @@
  191.          {
  192.              while ((entry = readdir(procdir)) != NULL)
  193.              {
  194. +                char statf[0x80] = "u:/proc/";
  195. +                struct stat st;
  196. +
  197.                  entry->d_name[entry->d_namlen] = '\0';
  198.                  pointer = strchr(entry->d_name, '.');
  199.                  sscanf(++pointer, "%3d", &pid);
  200. -                if ((pid != getpid()) && (pid != 0))
  201. +                if (!updatepid && pid < getpid() && !strncmp
  202. +                    (entry->d_name, "update.", pointer-1-entry->d_name))
  203. +                    updatepid = pid;
  204. +
  205. +                /* don't wait() for update or TSRs...    -nox */
  206. +                strcpy (statf+sizeof "u:/proc", entry->d_name);
  207. +                if ((pid != getpid()) && (pid != 0) &&
  208. +                    (pid != updatepid) && !stat (statf, &st) &&
  209. +                    !(st.st_attr & FA_HIDDEN))
  210.                  {
  211.                      num_procs++;
  212.                      switch (first_time)
  213. diff -ru .b/syslog/syslogd.c ./syslog/syslogd.c
  214. --- .b/syslog/syslogd.c    Tue Aug 10 00:07:46 1993
  215. +++ ./syslog/syslogd.c    Thu Sep  2 14:39:28 1993
  216. @@ -134,6 +134,7 @@
  217.  char    ctty[] = CTTY;
  218.  
  219.  #ifdef atarist
  220. +#include <setjmp.h>
  221.  #include <osbind.h>
  222.  char    *PipeName = "\\pipe\\log";
  223.  #endif
  224. @@ -281,6 +282,22 @@
  225.  extern    char *sys_errlist[];
  226.  extern    char *ctime(), *index(), *calloc();
  227.  
  228. +#ifdef atarist
  229. +/* on MiNT fork and vfork both block until the child does either exec or
  230. +   dies.  only tfork doesn't block but it works like a subroutine call... */
  231. +static jmp_buf    tforkj;
  232. +
  233. +static int in_tfork(arg)
  234. +int arg;
  235. +{
  236. +    /* wait for parent to die before we can longjmp back */
  237. +    while (getppid () > 1)
  238. +        sleep (1);
  239. +    longjmp (tforkj, 1);
  240. +    /*NOTREACHED*/
  241. +}
  242. +#endif
  243. +
  244.  main(argc, argv)
  245.      int argc;
  246.      char **argv;
  247. @@ -327,6 +344,11 @@
  248.  #ifndef atarist
  249.          if (fork())
  250.              exit(0);
  251. +#else
  252. +        /* hack until MiNT gets a real nonblocking fork...  one day :)
  253. +        */
  254. +        if (!setjmp(tforkj) && tfork (in_tfork, 0) >= 0)
  255. +            _exit (0);
  256.  #endif
  257.  #ifdef SYSV
  258.          sleep(5);    /* Why wont it work without this?! -- ASP */
  259. -- 
  260. J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
  261.                                 ...ohne Gewehr
  262. PGP public key fingerprint =  8A 18 58 54 03 7B FC 12  1F 8B 63 C7 19 27 CF DA 
  263.